home *** CD-ROM | disk | FTP | other *** search
/ PC World 2004 December / PCWorld_2004-12_cd.bin / software / temacd / tiny / tf6pro-6[1].0.140.exe / Tiny Firewall Pro 6.0.msi / ExpCollapse.js < prev    next >
Encoding:
JavaScript  |  2004-07-20  |  6.3 KB  |  252 lines

  1. //Generic Display code
  2. //Updated 5/8/2000 - increased delay from 400 to 800
  3.  
  4. var L_COLLAPSE_TEXT="Hide All";
  5. var L_EXPAND_TEXT="Show All";
  6.  
  7. function ExpandAll()
  8. {
  9.     // Expand all 
  10.     var iSpan
  11.     var iSpanSource
  12.     var oSpan
  13.     var sCaption
  14.     var sAction
  15.     var sImage
  16.     
  17.     // Determine the action, and the picture to replace
  18.     sCaption=document.all("ExpandAll").innerHTML;
  19.     if (sCaption==L_EXPAND_TEXT)
  20.         {
  21.         sAction="expanded";
  22.         sImage="arrow-up.gif"
  23.         document.all("picHeader").src="collapsetri.gif";
  24.         document.all("ExpandAll").innerHTML=L_COLLAPSE_TEXT;
  25.         }
  26.     else
  27.         {
  28.         sAction="collapsed";
  29.         sImage="arrow-down.gif"
  30.         document.all("picHeader").src="expandtri.gif";
  31.         document.all("ExpandAll").innerHTML=L_EXPAND_TEXT;
  32.         }
  33.  
  34.     // Execute the action for all expand SPANs    
  35.     for (iSpan=0; iSpan < document.all.tags("DIV").length; iSpan++)
  36.         {    
  37.             oSpan=document.all.tags("DIV").item(iSpan);
  38.             iSpanSource=oSpan.sourceIndex;
  39.             if (oSpan.id=="ExpCol")
  40.             {
  41.                 document.all.tags("DIV").item(iSpan).className=sAction;
  42.                 document.all(iSpanSource-1).src=sImage;
  43.             }
  44.             
  45.         }
  46.  
  47.  
  48.     // Change the text and the picture of the main caller
  49.     document.all("ExpandAll").className="DropDown";
  50.  
  51.     // Now we do the inline defs
  52.     var cLinks = document.all.tags("A");
  53.     var iNumLinks = cLinks.length;
  54.  
  55.       for (var i=0;i<iNumLinks;i++)
  56.       {
  57.         cLink=document.all.tags("A").item(i);
  58.         
  59.         switch (sAction)
  60.         {
  61.             case 'expanded':
  62.                 if (cLink.className=="glossary" && cLink.getAttribute("State")!="On")
  63.                 {
  64.                 cLinks[i].click();
  65.                 }
  66.                 else if (cLink.className=="HidePopUp")
  67.                 {
  68.                 cLinks[i].click();
  69.                 }
  70.                 
  71.                 break;
  72.             case 'collapsed':
  73.                 if (cLink.className=="glossary" && cLink.getAttribute("State")=="On")
  74.                 {
  75.                 cLinks[i].click();
  76.                 }
  77.                 else if (cLink.className=="HidePopUp")
  78.                 {
  79.                 cLinks[i].click();
  80.                 }
  81.                 break;
  82.         }
  83.       }
  84.  
  85.  
  86.     
  87.     
  88. }
  89.  
  90. function Outline2(num)
  91. {
  92.  
  93.     window.event.returnValue=0    
  94.  
  95.     //Expand or collapse if a list item is clicked.
  96.     var open = event.srcElement;
  97.  
  98.     //Verify that the tag which was clicked was either the 
  99.     //trigger tag or nested within a trigger tag.
  100.     var el = checkParent(open,"A");
  101.     if(null != el)
  102.     {    
  103.         var incr=0;
  104.         var elmPos = 0;
  105.         var parentSpan;
  106.         var fBreak
  107.  
  108.         //Get the position of the element which was clicked
  109.         elemPos = window.event.srcElement.sourceIndex;
  110.  
  111.         //Search for a SPAN tag
  112.         for (parentSpan = window.event.srcElement.parentElement;
  113.             parentSpan!=null;
  114.             parentSpan = parentSpan.parentElement) 
  115.         {
  116.             //test if already at a span tag 
  117.             if (parentSpan.tagName=="DIV") 
  118.             {
  119. //                alert("Parent Element is a SPAN");
  120.                 incr=1;
  121.                 break;
  122.             }
  123.             
  124.             //Test if the tag clicked was in a body tag or in any of the possible kinds of lists
  125.             //we perform this test because nested lists require special handling
  126.             if (parentSpan.tagName=="BODY" || parentSpan.tagName=="UL" || parentSpan.tagName=="OL"|| parentSpan.tagName=="P") 
  127.             {
  128.                 //Determine where the span to be expanded is.  
  129.                 for (incr=1; (elemPos+incr) < document.all.length; incr++)
  130.                 {    
  131.                     //verify we are at an expandable Div tag
  132.                     if(document.all(elemPos+incr).tagName=="DIV" && 
  133.                     (document.all(elemPos+incr).className=="expanded" ||
  134.                      document.all(elemPos+incr).className=="collapsed"))
  135.                     {
  136.                         fBreak=1;
  137.                         break;
  138.                     }
  139.                     //If the next tag following the list item (li) is another 
  140.                     //list item(li) return in order to prevent accidentally opening
  141.                     //the next span in the list
  142.                     else if(document.all(elemPos+incr).tagName=="LI")
  143.                     {
  144.                         return;
  145.                     }
  146.                 }
  147.             }
  148.             //determine if we need to break out of the while loop (kind of a kludge since theres no goto in javascript)
  149.             if(fBreak==1)
  150.             {
  151.                 break;
  152.             }
  153.         }
  154.  
  155.     }
  156.     else
  157.     {
  158.         Alert("Return!");
  159.         return;
  160.     }
  161.  
  162.     //Now that we've identified the span, expand or collapse it
  163.     if(document.all(elemPos+incr).className=="collapsed")
  164.     {
  165.         document.all(elemPos+incr).className="expanded";
  166.         document.all(elemPos+1).src="blueup.gif";
  167.         if(open.tagName=="IMG"){open.src="blueup.gif";}
  168.         if(open.tagName=="B")
  169.             {
  170.             if(open.parentElement.all.tags("IMG").length != 0)
  171.                 {open.parentElement.all.tags("IMG").item(0).src="blueup.gif";}
  172.             }
  173.     }
  174.     else if(document.all(elemPos+incr).className=="expanded")
  175.     {
  176.         document.all(elemPos+incr).className="collapsed";
  177.         document.all(elemPos+1).src="bluedrop.gif";
  178.         if(open.tagName=="IMG"){
  179.         open.src="bluedrop.gif";
  180.         }
  181.         if(open.tagName=="B")
  182.             {
  183.             if(open.parentElement.all.tags("IMG").length != 0)
  184.                 {open.parentElement.all.tags("IMG").item(0).src="bluedrop.gif";}
  185.             }
  186.     }
  187.     else
  188.     {
  189.         return;
  190.     }
  191.     event.cancelBubble = true;
  192. //    open.scrollIntoView(true);
  193. }
  194.  
  195.  
  196. function checkParent(src,dest)
  197. {
  198.     //Search for a specific parent of the current element.
  199.     while(src !=null)
  200.     {
  201.         if(src.tagName == dest)
  202.         {
  203.             return src;
  204.         }
  205.         src = src.parentElement;
  206.     }
  207.     return null;
  208. }
  209.  
  210. //This function displays content from different source HTML files
  211. function showPopup(filename, theSpan){
  212.  
  213.  
  214.     //Get the position of the element which was clicked
  215.     elemPos = window.event.srcElement.sourceIndex;
  216.     theIFRAME.location.replace(filename);
  217.     tempSpan = theSpan
  218.     window.setTimeout("showPopup2(tempSpan,elemPos)", 800)
  219.     
  220.  
  221. }
  222.  
  223. function showPopup2(theSpan, elemPos){
  224. //var elemPos=0;
  225. //Get the position of the element which was clicked
  226. //elemPos = window.event.srcElement.sourceIndex;
  227.  
  228.     defSpan = document.all(theSpan);
  229.     if (defSpan && document.readyState == "complete" && theIFRAME.document.readyState == "complete"){
  230.             if (defSpan.style.display == "none"){
  231.             theIFRAME.document.all.tags("H1").item(0).outerHTML="";
  232.             
  233.             if(theIFRAME.document.all.tags("P").item("ExpandAllLine") != null) {theIFRAME.document.all.tags("P").item("ExpandAllLine").outerHTML="";}            
  234.             ///defSpan.innerHTML = theIFRAME.document.all.glosdef.innerHTML;
  235.             defSpan.innerHTML = theIFRAME.document.body.innerHTML;
  236.             defSpan.style.display = "";
  237.             defSpan.parentElement.style.display = "";
  238.  
  239.             document.all(elemPos+1).src="arrow-up.gif";
  240.             document.all(elemPos).src="arrow-up.gif";
  241.         }
  242.             else{
  243.             defSpan.style.display = "none";
  244.             defSpan.parentElement.style.display = "none";
  245.             document.all(elemPos+1).src="arrow-down.gif";
  246.             //if(oSource.tagName=="IMG"){open.src="arrow-down.gif";}
  247.             }
  248.     }
  249. }
  250.  
  251.  
  252.